<%--
  Created by IntelliJ IDEA.
  User: zuxia
  Date: 2018/7/19
  Time: 14:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="css/amazeui.min.css">
    <link rel="stylesheet" href="css/admin.css">
</head>
<style type="text/css">
</style>
<body>
<div class="admin-content-body"style="" >
    <div class="am-cf am-padding am-padding-bottom-0" >
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">菜品类型管理</strong><small></small></div>
    </div>
    <hr>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <button type="button" class="am-btn am-btn-default btnAdd">
                        <span class="am-icon-plus"></span> 新增
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div class="am-g" style="margin-top: -30px;">
        <div class="am-u-sm-12">
            <form class="am-form">
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                    <tr>
                        <th class="table-check">
                            <input id="chkAll" type="checkbox">
                        </th>
                        <th class="table-id">
                            ID
                        </th>
                        <th class="table-title">
                            菜品类型名称
                        </th>
                        <th class="table-set">
                            操作
                        </th>
                    </tr>
                    </thead>
                    <tbody id="tUser">

                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>
</div>
<!-- content end -->
</div>
</div>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->


<!--[if (gte IE 9)|!(IE)]><!-->
<script src="js/jquery-1.11.3.min.js"></script>
<!--<![endif]-->
<script type="text/javascript" src="myplugs/js/plugs.js"></script>

<script>
    $(function() {

        $.ajax({
            type: "get",//使用post方法访问后台
            dataType: "json",//返回json格式的数据
            url: "/isFull-admin/typelist.action",//要访问的后台地址
            contentType: "application/json;charset=utf-8",
            data: { },//要发送的数据
            success: function(data){//data为返回的数据，在这里做数据绑定
                var types = data.data;
                for(var i=0;i<types.length;i++){
                    var type = types[i];
                    $("#tUser").append(
                        "<tr><td><input name='chks' type='checkbox' value='"+type.tid+"' /></td>" +
                        "<td>"+type.tid+"</td><td>"+type.tName+"</td><td> <div class='am-btn-toolbar'>" +
                        "<div class='am-btn-group am-btn-group-xs'>" +
                        "<button type='button' id='depart_14' class='am-btn am-btn-default am-btn-xs am-text-secondary btnedit'>" +
                        "<span class='am-icon-pencil-square-o'></span> 编辑</button>" +
                        "<button type='button' class='am-btn am-btn-default am-btn-xs am-text-danger amt-hide-sm-only  btndel' onclick='deleteDepart(14,1)'>" +
                        "<span class='am-icon-trash-o'></span> 删除</button></div> </div> </td> </tr>"
                    )
                }
            }
        });
        $("#chkAll").click(function () {
            if($(this).prop("checked")){
                $("input[name=chks]").prop("checked",true);
            }else{
                $("input[name=chks]").prop("checked",false);
            }
        })

        $("body").on("click",'.btnedit',function() {

            var typeId = $(this).parents("tr").children(":first").children("input").val();

            $.ajax({
                type:"get",
                dataType:"json",
                data:{ typeId },
                async: false,
                url:'/isFull-admin/typeSingle.action',
                success:function () {
                }
            })
            $.jq_Panel({
                title: "修改菜品类型",
                iframeWidth: 500,
                iframeHeight: 300,
                url: "editMenuType.jsp"
            });
        });

        $("body").on("click",'.btndel',function() {
            var typeId = $(this).parents("tr").children(":first").children("input").val();
            $.ajax({
                type:"get",
                dataType:"json",
                data:{ typeId },
                url:'/isFull-admin/deleteType.action',
                success:function () {
                    $(location).prop('href', '/isFull-admin/menutype.jsp');
                }
            })
        });

        $(".btnAdd").click(function() {
            $.jq_Panel({
                title: "添加菜品类型",
                iframeWidth: 500,
                iframeHeight: 300,
                url: "addMenuType.jsp"
            });
        });
    });

</script>
</body>

</html>